class Solution01 {
	// 滑动窗口
    public int minSubArrayLen(int target, int[] nums) {
        int left = 0;
        int right = left;
		int sum = 0;
		int len = Integer.MAX_VALUE;
		while(right < nums.length){
			sum += nums[right];
			while(sum >= target){ // 满足条件，左指针移动
				len = Math.min(len, right - left + 1);
				sum -= nums[left++];
			}
			right++; // 不满足条件，右指针移动
		}
		return len == Integer.MAX_VALUE ? 0 : len;
    }
}
